package com.cn.demo4.service.impl;

import com.cn.demo4.dao.CompanyDao;
import com.cn.demo4.dao.impl.CompanyDaoImpl;
import com.cn.demo4.model.CompanyModel;
import com.cn.demo4.service.ICompanyService;

import java.util.List;

public class CompanyServiceImpl implements ICompanyService {
    @Override
    public List<CompanyModel> findAll(CompanyModel companyModel) {
        CompanyDao companyDao = new CompanyDaoImpl();
        return companyDao.findAll(companyModel);
    }

    @Override
    public String add(CompanyModel companyModel) {
        CompanyDao companyDao = new CompanyDaoImpl();
        return companyDao.add(companyModel) == 1 ? "success" : "error";
    }

    @Override
    public CompanyModel findById(Integer id) {
        CompanyDao companyDao = new CompanyDaoImpl();
        return companyDao.findById(id);
    }

    @Override
    public String update(CompanyModel companyModel) {
        CompanyDao companyDao = new CompanyDaoImpl();
        return companyDao.update(companyModel) == 1 ? "success":"error";
    }

    @Override
    public int del(Integer id) {
        CompanyDao companyDao = new CompanyDaoImpl();
        return companyDao.del(id);
    }
/*
*前台首页
*
*/
    @Override
    public List<CompanyModel> getCompanyModelListForHome() {
        CompanyDao companyDao = new CompanyDaoImpl();
        return companyDao.getCompanyModelListForHome();
    }

    @Override
    public int getCount(CompanyModel companyModel) {
        CompanyDao companyDao = new CompanyDaoImpl();
        return companyDao.getCount(companyModel);
    }
}
